home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-05 | 2.5 KB | 100 lines | [TEXT/ALFA] |
- // CD Playthrough
- // Version: 1.5 <October 3, 1994>
- // (c) 1994 neg.active.productions, jwang@csua.berkeley.edu <James Wang>
- // ftp://ftp.csua.berkeley.edu/pub/jwang/cool/cd-playthrough-15.hqx
-
- // File: Prefs.c
- //
- // Contains: Preferences reading and writing sub-routines
- //
- // Written by: James Wang
- //
- // Description: CD Playthrough modifies its own resources ('PREF') to remember
- // the "user" mode options. This file needs to be re-written to
- // use bona fide preference files (with drag-n-drop). Any takers?
-
-
- #include "main.h"
-
-
- Str31 sourStr, plthStr, rateStr;
- Handle sourHand, plthHand, rateHand;
-
-
- void res_check(SoundSetting *mySnd)
- {
- sourHand = Get1Resource('PREF', kSourPrefID);
- if (sourHand == 0)
- {
- sourHand = NewHandle(1);
- if (sourHand == 0) stop_alert(MemFull);
- **sourHand = kSourCD;
- AddResource(sourHand, 'PREF', kSourPrefID, "\pInput Source");
- // handle_res_error(ResError());
- }
-
- plthHand = Get1Resource('PREF', kPlthPrefID);
- if (plthHand == 0)
- {
- plthHand = NewHandle(1);
- if (plthHand == 0) stop_alert(MemFull);
- **plthHand = kPlthMax;
- AddResource(plthHand, 'PREF', kPlthPrefID, "\pPlaythrough Level");
- // handle_res_error(ResError());
- }
-
- rateHand = Get1Resource('PREF', kRatePrefID);
- if (rateHand == 0)
- {
- rateHand = NewHandle(6);
- if (rateHand == 0) stop_alert(MemFull);
- NumToString(44100L, *((StringHandle)rateHand));
- AddResource(rateHand, 'PREF', kRatePrefID, "\pSound Out Rate");
- // handle_res_error(ResError());
- }
- }
-
- void read_prefs(SoundSetting *mySnd)
- {
- long myRate;
-
- res_check(mySnd);
- mySnd->siWantSour = (short)**sourHand;
- mySnd->siWantPlth = (short)**plthHand;
- StringToNum(*((StringHandle)rateHand), &myRate);
- mySnd->soWantRate = myRate<<16;
- }
-
- void save_prefs(SoundSetting *mySnd)
- {
- res_check(mySnd);
-
- GetIndString(sourStr, kSourStrID, mySnd->siCurrSour);
- GetIndString(plthStr, kPlthStrID, mySnd->siCurrPlth+1);
- NumToString(mySnd->soCurrRate>>16, rateStr);
-
- ParamText(sourStr, plthStr, rateStr, 0);
- if (CautionAlert(kCautionAlertID, 0) == 2) return;
-
- **sourHand = (char)mySnd->siCurrSour;
- **plthHand = (char)mySnd->siCurrPlth;
- SetString((StringHandle)rateHand, rateStr);
-
- ChangedResource(sourHand);
- ChangedResource(plthHand);
- ChangedResource(rateHand);
- // handler_res_error(ResError());
- }
-
- void system_prefs(SoundSetting *mySnd)
- {
- mySnd->siWantSour = kSourAV;
- mySnd->siWantPlth = kPlthMin;
-
- // lame machine identity test
- if (desired_rate_available(kRate24000))
- mySnd->soWantRate = kRate24000; // we have a 660av or 840av
- else
- mySnd->soWantRate = kRate22050; // assume a Power Macintosh
- }
-